package com.sweet.fourtimeoa.controller;

import com.sweet.fourtimeoa.pojo.entity.BookBorrowing;
import com.sweet.fourtimeoa.properties.BaseException;
import com.sweet.fourtimeoa.service.AdministrationService;
import com.sweet.fourtimeoa.util.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Tag(name = "行政管理")
@RestController
@RequestMapping("/oa/administration")
@CrossOrigin(origins = "*")
public class AdministrationController {
    @Autowired
    private AdministrationService administrationService;

    // 新增图书借阅
    @Operation(summary = "图书借阅")
    @PostMapping("/borrowBook")
    public Result addAdministration(@RequestBody BookBorrowing administration) {
        administrationService.borrowBook(administration);
        return Result.success();
    }

    @Operation(summary = "测试异常")
    @PostMapping("/test")
    public void test() {
        int i = 0;
        throw new BaseException("测试异常");
    }
}
